const express = require('express');
const router = express.Router();
const orderController = require('../controllers/orderController');
const { authMiddleware } = require('../middleware/auth');

// 应用认证中间件
router.use(authMiddleware);

// 获取所有订单
router.get('/', orderController.getAllOrders);

// 获取单个订单
router.get('/:id', orderController.getOrderById);

// 创建订单
router.post('/', orderController.createOrder);

// 更新订单状态
router.put('/:id/status', orderController.updateOrderStatus);

// 通过订单号更新订单状态
router.put('/by-order-no/:orderNo/status', orderController.updateOrderStatusByOrderNo);

// 添加支付记录
router.post('/:id/payments', orderController.addPayment);

module.exports = router; 